import { create } from 'zustand';
import { persist } from 'zustand/middleware';

interface GlobalState {
  settings: {
    theme: 'light' | 'dark';
  };
  setTheme: (theme: 'light' | 'dark') => void;
}

export const useGlobalStore = create<GlobalState>()(
  persist(
    (set) => ({
      settings: {
        theme: 'light',
      },
      setTheme: (theme) => set((state) => ({
        settings: { ...state.settings, theme }
      })),
    }),
    {
      name: 'global-storage',
    }
  )
);